<template>
  <div id="attachment" class="box">
    <attachment :code="code" :fujian-obj-list="fujianObjList" />
  </div>
</template>

<script>
import { attachmentList } from '@/api/common'
import attachment from '@/components/attachmentForThree'
export default {
  components: {
    attachment
  },
  data() {
    return {
      fujianObjList: [],
      code: 'FEASIBILITY'
    }
  },
  mounted() {
    this.getFujian()
  },
  methods: {
    // 获取附件列表
    getFujian() {
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      var data = {
        projectId: localStorage.getItem('projectId'),
        key: this.code
      }
      attachmentList(data)
        .then(res => {
          loading.close()
          if (res.data) {
            var arr = []
            if (res.data.attachment) {
              arr.push({ title: '附件', list: res.data.attachment })
            }
            if (res.data.design) {
              arr.push({ title: '单体设计图', list: res.data.design })
            }
            if (res.data.drawing) {
              arr.push({ title: '图件', list: res.data.drawing })
            }
            this.fujianObjList = arr
          }
        })
        .catch(() => {
          loading.close()
        })
    }
  }
}
</script>